package com.situ.day09;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;

import javax.sql.rowset.serial.SerialArray;

import java.util.Set;

import org.junit.Test;

import com.situ.day05.Student;

public class CollectionDemo {
	
	@Test
	public void test1() {
		ArrayList<Student> list =new ArrayList<Student>();
		Student student1 = new Student(1, "张三1", 23,"dd");
		Student student2 = new Student(2, "张三2", 23,"dd");
		Student student3 = new Student(3, "张三3", 23,"dd");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		for (Student student : list) {
			System.out.println(student);
		}
	}
	
	@Test
	public void test12() {
		HashSet<Student> set = new HashSet<Student>();
		Student student1 = new Student(1, "张三1", 23,"dd");
		Student student2 = new Student(2, "张三2", 23,"dd");
		Student student3 = new Student(3, "张三3", 23,"dd");
		set.add(student1);
		set.add(student2);
		set.add(student3);
		for (Student student : set) {
			System.out.println(student);
		}
	}
	
	@Test
	public void test2() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("CN", "中华人民共和国");
		map.put("US", "美利坚合众国");
		String value1 = map.get("CN");
		System.out.println(value1);
		//Map遍历
		Set<Entry<String, String>> set = map.entrySet();
		for (Entry<String, String> entry : set) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("key:"+key+"value:"+value);
		}
		//遍历
		Set<String> keySet=map.keySet();
		for (String key : keySet) {
			String value = map.get(key);
			System.out.println("key:" + key + ",value:" + value);
		}
	}
	
	@Test
	public void test3() {
		String string = "20";
		int value = Integer.parseInt(string);
		System.out.println(value);
		String string2 = "true";
		Boolean value2 = Boolean.parseBoolean(string2);
		System.out.println(value2);
	}
}
